package com.zjsd.sqeybusiness.service.impl;

import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.utils.DateUtils;
import com.zjsd.sqeybusiness.domain.*;
import com.zjsd.sqeybusiness.mapper.ShareInfoMapper;
import com.zjsd.sqeybusiness.service.IShareInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ShareInfoServiceImpl implements IShareInfoService {
    @Autowired
    private ShareInfoMapper shareInfoMapper;

    @Override
    public int insertShareInfo(ShareInfo shareInfo) {

        shareInfo.setFbsj(DateUtils.getNowDate());
        return shareInfoMapper.insertShareInfo(shareInfo);
    }

    @Override
    public List<ShareInfo> selectShareInfoList(ShareInfo shareInfo) {
        System.out.println("=========================================");
        System.out.println("开始时间：" + shareInfo.getFbsjks());
        System.out.println("结束时间：" + shareInfo.getFbsjks());
        return shareInfoMapper.selectShareInfoList(shareInfo);
    }

    @Override
    public int insertShareStoreInfo(ShareStore shareStore) {

        ShareStore shareStore1 = shareInfoMapper.selectShareStoreInfo(shareStore);
        if(shareStore1 != null){
            shareStore1.setScsj(new Date());
            shareStore1.setDzsj(new Date());
            shareStore1.setScyxbz(shareStore.getScyxbz());
            shareStore1.setDzyxbz(shareStore.getDzyxbz());
            return  shareInfoMapper.updateShareStoreInfo(shareStore1);
        }else{
            shareStore.setScsj(new Date());
            shareStore.setDzsj(new Date());
            return shareInfoMapper.insertShareStoreInfo(shareStore);
        }
    }

    @Override
    public int updateShareReadNum(ShareInfo shareInfo) {


        return shareInfoMapper.updateShareReadNum(shareInfo);

    }

    @Override
    public int insertShareLy(ShareLy shareLy) {

        shareLy.setLysj(new Date());
        return shareInfoMapper.insertShareLy(shareLy);

    }

    @Override
    public List<ShareLy> selectShareLyList(ShareInfo shareInfo) {
        return shareInfoMapper.selectShareLyList(shareInfo);
    }

    @Override
    public List<ShareInfo> selectMySharedInfoList(ShareInfo shareInfo) {
        return shareInfoMapper.selectMySharedInfoList(shareInfo);
    }

    @Override
    public List<ShareInfo> selectMyStoredShareInfoList(ShareInfo shareInfo) {
        return shareInfoMapper.selectMyStoredShareInfoList(shareInfo);
    }

    @Override
    public List<ShareInfo> selectHasMyLyShareInfoList(ShareInfo shareInfo) {
        return shareInfoMapper.selectHasMyLyShareInfoList(shareInfo);
    }

    @Override
    public AgencyInfo selectAgencyInfo(Long agencyid) {
        return shareInfoMapper.selectAgencyInfo(agencyid);
    }

    @Override
    public ShareInfo selectShareInfoById(Long shareid) {
        return shareInfoMapper.selectShareInfoById(shareid);
    }

    @Override
    public int updateShareInfo(ShareInfo shareInfo) {
        return shareInfoMapper.updateShareInfo(shareInfo);
    }

    @Override
    public int deleteShareInfoByIds(Long[] shareids) {
        return 0;
    }

    @Override
    public int deleteShareInfoById(Long shareid) {
        return 0;
    }

    @Override
    public SysDept getDeptInfoByUserId(Long userId) {
        return shareInfoMapper.getDeptInfoByUserId(userId);
    }

    @Override
    public CompanyInfo getCompanyInfoByDeptId(Long deptId) {
        return shareInfoMapper.getCompanyInfoByDeptId(deptId);
    }


}
